package com.googlecode.ebasys.web;

/**
 * A View Configuration class that is responsible for setting template layout,
 * content and navigation sub-templates, page title and other view
 * related attributes. All templates are fetched from respective module.
 * 
 * Module template structure is searched in classpath and is as follows:
 * <pre>
 * - /templates
 *   - /module1
 *     - /layout
 *       - /layout1.ftl
 *       - /layout2.ftl
 *     - /navigation
 *       - /navi1.ftl
 *       - /navi2.ftl
 *     - /content 
 *       - /content1.ftl
 *       - /content2.ftl
 *   - /module2
 *     ...
 * </pre>
 * 
 * @author Tomas Varaneckas
 * @version $Id: ViewConfiguration.java 54 2009-01-18 07:05:07Z tomas.varaneckas $
 */
public class ViewConfiguration {
    
    /**
     * Freemarker template suffix
     */
    private static final String TEMPLATE_SUFFIX = ".html";

    /**
     * Main layout template name
     */
    private String layout;

    /**
     * Sets navigation sub-template name
     */
    private String navigation;

    /**
     * Sets content sub-template name
     */
    private String content;

    /**
     * Sets page title
     */
    private String title;

    /**
     * Sets template module
     */
    private String module;

    /**
     * Gets main layout template according to current module
     * 
     * @return
     * @see #theme
     */
    public String getLayout() {
        return module + "/layout/" + layout;
    }

    /**
     * Sets layout template name
     * 
     * @param layout
     */
    public void setLayout(final String layout) {
        this.layout = layout;
    }

    /**
     * Gets module name
     * 
     * @return module name
     */
    public String getModule() {
        return module;
    }

    /**
     * Sets template module name
     * 
     * @param theme
     */
    public void setModule(final String module) {
        this.module = module;
    }

    /**
     * Gets navigation sub-template according to current module
     * 
     * @return path to navigation sub-template
     */
    public String getNavigation() {
        return "/" + module + "/navigation/" + navigation + TEMPLATE_SUFFIX;
    }

    /**
     * Sets navigation sub-template name
     * 
     * @param navigation
     */
    public void setNavigation(final String navigation) {
        this.navigation = navigation;
    }

    /**
     * Gets content sub-template according to current module
     * 
     * @return path to content sub-template
     */
    public String getContent() {
        return "/" + module + "/content/" + content + TEMPLATE_SUFFIX;
    }

    /**
     * Sets content sub-template name
     * 
     * @param content
     */
    public void setContent(final String content) {
        this.content = content;
    }

    /**
     * Gets page title
     * 
     * @return page title
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets page title
     * 
     * @param title
     */
    public void setTitle(final String title) {
        this.title = title;
    }

}
